package com.hl.mapper;

import com.hl.pojo.PsychologicalAssessment;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface PsychologicalAssessmentMapper {
    // 添加心理测评
    @Insert("insert into psychological_assessment (assessment_name, assessment_intro, list_image, question_count) values (#{assessmentName},#{assessmentIntro},#{listImage},#{questionCount})")
    public Integer add(PsychologicalAssessment psychologicalAssessment);

    // 查询所有心理测评
    @Select("select p.*,p.id id1 from psychological_assessment p where del = 0")
    @Results({
            @Result(property = "sum",column = "id1",one = @One(select = "a"))
    })
    public List<PsychologicalAssessment> findAll();

    @Select("select count(*) from psychological_topic where pa_id = #{id}")
    public Integer a(Integer id);



    // 根据id删除心理测评
    @Update("update psychological_assessment set del = 1 where id = #{id}")
    public Integer del(Integer id);

    // 根据id查询心理测评
    @Select("select * from psychological_assessment where id = #{id}")
    public PsychologicalAssessment findById(Integer id);

    // 更新心理测评
    @Update("update psychological_assessment set assessment_name=#{assessmentName}, assessment_intro=#{assessmentIntro}, list_image=#{listImage}, question_count=#{questionCount} where id=#{id}")
    public Integer update(PsychologicalAssessment psychologicalAssessment);
}